package com.cw.realtime.common
package bean

import io.circe.generic.JsonCodec
import io.circe.generic.auto._

case class TrafficPageViewBean(
  vc: String, // app 版本号
  ch: String, // 渠道
  ar: String, // 地区
  is_new: String, // 新老访客状态标记
  uv_ct: Long, // 独立访客数
  sv_ct: Long, // 会话数
  pv_ct: Long, // 页面浏览数
  dur_sum: Long, // 累计访问时长
  ts: Long, // 时间戳, 不用序列化
  sid: String, // 会话id, 不用序列化
  stt: String = "", // 窗口起始时间
  edt: String = "", // 窗口结束时间
  cur_date: String = "", // 当天日期
) {

  def +(that: TrafficPageViewBean): TrafficPageViewBean =
    TrafficPageViewBean(
      vc, ch, ar, is_new, uv_ct + that.uv_ct, sv_ct + that.sv_ct, pv_ct + that.pv_ct, dur_sum + that.dur_sum, ts, sid, stt, edt, cur_date
    )


  def transWindowRange(stt: String, edt: String, curDate: String): TrafficPageViewBean =
    TrafficPageViewBean(
      vc, ch, ar, is_new, uv_ct, sv_ct, pv_ct, dur_sum, ts, sid, stt, edt, curDate
    )


}